package com.atfcm.stack;

import java.util.LinkedList;
import java.util.Stack;

/**
 * @Author 96534
 * @create 2025/3/11 10:51
 */

class Node<T> {
    T data;
    Node<T> next;

    Node() {

    }

    Node(T data) {
        this.data = data;
    }
}

public class MyLinkStack<T> {
    Node<T> top;

    public MyLinkStack() {
    }

    public boolean isEmpty() {
        return top == null;
    }

    public boolean isFull() {
        return false;
    }

    public void push(T value) {
        Node node = new Node(value);
        node.next = top;
        top = node;
    }

    public T pop() {
        if (isEmpty()) {
            throw new RuntimeException("Stack is empty");
        }
        T data = top.data;
        top = top.next;
        return data;
    }

    public T peek() {
        if (isEmpty()) {
            throw new RuntimeException("Stack is empty");
        }
        return top.data;
    }


}
